﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Sbook
{
    public partial class MyShopDetail : System.Web.UI.Page
    {
        protected static string DeId = "";
        protected static string DId = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DId = Request.QueryString["DId"];
                BindData(DId);
            }
        }

        private void BindData(string DId)
        {
            grdShopDetail.DataSource = Business.DeliveryDetailService.DeliveryDetail_GetByAll().FindAll(de => de.DeliveryId == DId);
            grdShopDetail.DataBind();
            for (int i = 0; i < grdShopDetail.Items.Count; i++)
            {
                grdShopDetail.Items[i].Cells[1].Text = Business.ProductsService.Products_GetById(grdShopDetail.Items[i].Cells[1].Text)[0].PName;
            }
        }
        //protected void grdShopDetail_ItemCommand(object sender, DataGridCommandEventArgs e)
        //{
        //    string[] arrA = e.CommandArgument.ToString().Split(':');
        //    string strCA = e.CommandArgument.ToString();
        //    switch (e.CommandName)
        //    {
        //        case "Edit":
        //            Data.DeliveryDetailInfo obj = new Data.DeliveryDetailInfo();
        //            obj.Qty = ((TextBox)e.Item.FindControl("txtQuantity")).Text;
        //            obj.ProductId = arrA[1];
        //            obj.DeliveryId = arrA[0];
        //            obj.Price = e.Item.Cells[2].Text;
        //            obj.Remark = "";
        //            obj.Location = Business.DeliveryDetailService.DeliveryDetail_GetByAll().Find(det => det.DeliveryId == arrA[0] && det.ProductId == arrA[1]).Location;
        //            Business.DeliveryDetailService.DeliveryDetail_Update(obj);
        //            BindData(DId);
        //            break;
        //        case "Delete":
        //            Business.DeliveryDetailService.DeliveryDetail_Delete(arrA[0], arrA[1]);
        //            BindData(DId);
        //            break;
        //    }
        //}
        protected void lbtEdit_Click(object sender, EventArgs e)
        {
            LinkButton link = sender as LinkButton;
            string PId = link.CommandArgument.ToString();
            Response.Write("<script>alert('"+PId+"');</script>");
        }
    }
}